﻿<UserControl x:Class="Framework.UI.TestHarness.Views.ScrollView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:params="http://schemas.codeplex.com/elysium/params"
             xmlns:extra="http://schemas.extra.com/ui"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="200"/>
        </Grid.RowDefinitions>

        <TextBlock Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                   Style="{StaticResource HeaderTextStyle}" 
                   Text="Scroll Bars"/>

        <TextBlock Grid.Row="1" 
                   Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                   Style="{StaticResource NormalTextStyle}" 
                   Text="The very thin default Elysium scroll bars were found to be too difficult to use by users so these were be modified to be thicker."/>

        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <ScrollBar/>

            <ScrollBar Grid.Column="1" 
                       Orientation="Horizontal"/>

        </Grid>

        <TextBlock Grid.Row="3" 
                   Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                   Style="{StaticResource HeaderTextStyle}" 
                   Text="ScrollViewer Problem"/>

        <TextBlock Grid.Row="4" 
                   Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                   Style="{StaticResource NormalTextStyle}" 
                   Text="Using a ScrollViewer around a control like ListBox/DataGrid/ScrollViewer/TreeView which already has a ScrollViewer in its template stops middle click scrolling from working, even if you set HorizontalScrollBarVisibility and VerticalScrollBarVisibility to Disabled. Another scenario is having a ListBox/DataGrid/ScrollViewer/TreeView inside a DataGrid's RowDetailsTemplate."/>

        <ScrollViewer Grid.Row="5">
            <StackPanel>

                <TextBlock Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                           Style="{StaticResource NormalTextStyle}" 
                           Text="Middle click scrolling works if your mouse is over this text but stops working if it is over the ListBox, unless you set UIElementAttached.IsBubblingMouseWheelEvents to tru on the ListBox."/>
                
                <CheckBox x:Name="CheckBox" 
                          Content="Fix Middle Click Scrolling"
                          Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}"
                          VerticalAlignment="Center"/>

                <ListBox extra:UIElementAttached.IsBubblingMouseWheelEvents="{Binding ElementName=CheckBox, Path=IsChecked}"
                         ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                         ScrollViewer.VerticalScrollBarVisibility="Disabled"
                         Margin="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}">
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                    <ListBoxItem>This is a ListBoxItem</ListBoxItem>
                </ListBox>

            </StackPanel>
        </ScrollViewer>

    </Grid>
</UserControl>
